/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

/*********************** Macro Dest language **********************/
#if defined(SWIGPYTHON)

#define SwigInt_FromCInt                  PyInt_FromLong
#define SwigInt_FromCUInt                 PyLong_FromUnsignedLong
#define SwigInt_FromCULongLong            PyLong_FromUnsignedLongLong
#define SwigInt_FromCLongLong             PyLong_FromLongLong
#define SwigFloat_FromCDouble             PyFloat_FromDouble
#define SwigFloat_FromCFloat              PyFloat_FromDouble

#define CInt_FromSwigInt                  PyInt_AsLong
#define CUInt_FromSwigInt                 PyLong_AsUnsignedLong
#define CLongLong_FromSwigInt             PyLong_AsLongLong
#define CULongLong_FromSwigInt            PyLong_AsUnsignedLongLong
#define CDouble_FromSwigFloat             PyFloat_AsDouble
#define CFloat_FromSwigFloat              PyFloat_AsDouble

#define SwigStringLen                     PyString_Size
#define SwigString_FromCString            PyString_FromString
#define CString_FromSwigString            PyString_AsString

#define SwigCreateArray                   PyList_New
#define SwigSetArrayVal(tab,index,value)  PyList_SetItem(tab,index,value)
#define SwigGetArrayVal(tab,index)        PyList_GetItem(tab,index)
#define SwigArraySize(tab)                PyList_Size(tab)

#define SwigCheckIntType(x)               (PyInt_Check(x) || PyLong_Check(x))
#define SwigCheckDblType(x)               PyFloat_Check(x)
#define SwigCheckStringType(x)            PyString_Check(x)
#define SwigCheckArrayType(x)             PyList_Check(x)

#define SwigObject                        PyObject*
#define SwigObjectEmpty                   NULL
#define SwigTrue                          Py_True
#define SwigFalse                         Py_False



#elif defined(SWIGRUBY)




#define SwigInt_FromCInt                  INT2NUM
#define SwigInt_FromCUInt                 UINT2NUM
#define SwigInt_FromCULongLong            ULL2NUM
#define SwigInt_FromCLongLong             LL2NUM
#define SwigFloat_FromCDouble             rb_float_new
#define SwigFloat_FromCFloat              rb_float_new

#define CInt_FromSwigInt                  NUM2INT
#define CUInt_FromSwigInt                 NUM2UINT
#define CLongLong_FromSwigInt             NUM2LL
#define CULongLong_FromSwigInt            NUM2ULL
#define CDouble_FromSwigFloat             NUM2DBL
#define CFloat_FromSwigFloat              NUM2DBL

#define SwigStringLen(str)                RSTRING(str)->len
#define SwigString_FromCString            rb_str_new2
#define CString_FromSwigString(str)       RSTRING(str)->ptr

#define SwigCreateArray                   rb_ary_new2
#define SwigSetArrayVal(tab,index,value)  rb_ary_store(tab,index,value)
#define SwigGetArrayVal(tab,index)        rb_ary_entry(tab,index)
#define SwigArraySize(tab)                RARRAY(tab)->len

#define SwigCheckIntType(x)               (TYPE(x)==T_FIXNUM)
#define SwigCheckDblType(x)               (TYPE(x)==T_FLOAT)
#define SwigCheckArrayType(x)             (!(NIL_P(rb_check_array_type(x))))
#define SwigCheckStringType(x)            (!(NIL_P(rb_check_string_type(x))))

#define SwigObject                        VALUE
#define SwigObjectEmpty                   Qnil
#define SwigTrue                          Qtrue
#define SwigFalse                         Qfalse





#elif defined(SWIGJAVA)

#define SwigInt_FromCInt                  (jint)
#define SwigInt_FromCUInt                 (jint)
#define SwigInt_FromCULongLong            (jlong)
#define SwigInt_FromCLongLong             (jlong)
#define SwigFloat_FromCDouble             (jfloat)
#define SwigFloat_FromCFloat              (jdouble)

#define CInt_FromSwigInt                  (int)
#define CUInt_FromSwigInt                 (unsigned int)
#define CLongLong_FromSwigInt             (long long)
#define CULongLong_FromSwigInt            (unsigned long long)
#define CDouble_FromSwigFloat             (float)
#define CFloat_FromSwigFloat              (double)

#else

#error "No support for this language"

#endif















typedef unsigned int          fgBIT;
typedef unsigned char         fgUINT8;
typedef unsigned short int    fgUINT16;
typedef unsigned int          fgUINT32;
typedef unsigned long long    fgUINT64;  
typedef char                  fgINT8;
typedef short int             fgINT16;
typedef int                   fgINT32;
typedef long long             fgINT64;
typedef float                 fgFLOAT32;
typedef double                fgFLOAT64;

typedef enum {
  FLGR_RET_OK                    = 0,
  FLGR_RET_TYPE_UNKNOWN          = -1,
  FLGR_RET_TYPE_DIFFERENT        = -2,
  FLGR_RET_SIZE_ERROR            = -3,
  FLGR_RET_ALLOCATION_ERROR      = -4,
  FLGR_RET_CONNEXITY_UNKNOWN     = -5,
  FLGR_RET_PARAM_UNKNOWN         = -6,
  FLGR_RET_NOT_IMPLEMENTED       = -7,
  FLGR_RET_UNDEFINED_ERROR       = -8,
  FLGR_RET_NULL_OBJECT           = -9,
  FLGR_RET_VECTOR_SIZE_DIFFERENT = -10,
  FLGR_RET_VECTOR_SIZE_ERROR     = -11,
  FLGR_RET_PARAM_ERROR           = -12
}FLGR_Ret;

/*! 
 *  Shape flags definition
 */
typedef enum {
  FLGR_LINE,       /*!< 1D Shape*/
  FLGR_RECT,       /*!< 2D, Rectangle */
  FLGR_HEX,        /*!< 2D, Hexagon */
  FLGR_DISC,       /*!< 2D, Disc */
  FLGR_ELLIPSE,    /*!< 2D, Filled ellipse */
  FLGR_CROSS,      /*!< 2D, Cross + */
  FLGR_CROSSX,     /*!< 2D, Cross X */
  FLGR_SLASH,      /*!< 2D, line / */
  FLGR_BSLASH,     /*!< 2D, line \\ */
  FLGR_DIAMOND,    /*!< 2D, Diamond */ 
  FLGR_OCTAGON,    /*!< 2D, Octagon */
  FLGR_USER_SHAPE, /*!< User shape */
  FLGR_NO_SHAPE,   /*!< Shape not applicable */
}FLGR_Shape;

/*! 
 *  Connexity Mesh flags definition
 */
typedef enum {
  FLGR_4_CONNEX  = 4, /*!< Flag for 4-connex operation (2D) */
  FLGR_6_CONNEX  = 6, /*!< Flag for 6-connex operation (2D) */
  FLGR_8_CONNEX  = 8, /*!< Flag for 8-connex operation (2D) */
  FLGR_NO_CONNEX = 0 /*!< Flag No Connexity applicable */
}FLGR_Connexity;

/*! 
 *  Data Types flags definition
 */
typedef enum {
  FLGR_BIT,         /*!< Flag for BIT type (one value is stored in one bit) */
  FLGR_UINT8,       /*!< Flag for UINT8 type */
  FLGR_UINT16,      /*!< Flag for UINT16 type */
  FLGR_UINT32,      /*!< Flag for UINT32 type */
  FLGR_UINT64,      /*!< Flag for UINT64 type */
  FLGR_INT8,        /*!< Flag for INT8 type */
  FLGR_INT16,       /*!< Flag for INT16 type */
  FLGR_INT32,       /*!< Flag for INT32 type */
  FLGR_INT64,       /*!< Flag for INT64 type */
  FLGR_FLOAT32,     /*!< Flag for FLOAT32 type */
  FLGR_FLOAT64     /*!< Flag for FLOAT64 type */
}FLGR_Type;

typedef enum {
  /*! Neihborhood Definition Symetrization Flag */
  FLGR_NHB_SYM              = 0,
  /*! Neihborhood Definition No Symetrization Flag */
  FLGR_NHB_NO_SYM           = 1,
}FLGR_Sym;

typedef enum {
  FLGR_MORPHO_OPTIM_SQUARE,     /*!< Flag for square kernel optimization (8-connex) */
  FLGR_MORPHO_OPTIM_CROSS,      /*!< Flag for cross kernel optimization (4-connex) */
  FLGR_MORPHO_OPTIM_HEXAGON,    /*!< Flag for hexagonal kernel optimization (6-connex) */
  FLGR_MORPHO_OPTIM_RECTANGLE,  /*!< Flag for rectangle kernel optimization (8-connex) */
  FLGR_MORPHO_OPTIM_OCTAGON,    /*!< Flag for octagon kernel optimization (8-connex) */
  FLGR_MORPHO_OPTIM_DIAMOND,    /*!< Flag for rhombus kernel optimization (8-connex) */
  FLGR_MORPHO_OPTIM_NONE        /*!< Flag for no specific kernel optimization */
}FLGR_MorphoOptim;



#define FLGR_TRUE  1
#define FLGR_FALSE 0

#define MAX_fgBIT (1)
#define MIN_fgBIT (0)

#define MAX_fgUINT8 (255)
#define MIN_fgUINT8 (0)

#define MAX_fgUINT16 (65535)
#define MIN_fgUINT16 0

#define MAX_fgUINT32 (4294967295U)
#define MIN_fgUINT32 (0)

#define MAX_fgUINT64 (18446744073709551615ULL)
#define MIN_fgUINT64 (0)

#define MAX_fgINT8 (127)
#define MIN_fgINT8 (-128)

#define MAX_fgINT16 (32767)
#define MIN_fgINT16 (-32767-1)

#define MAX_fgINT32 (2147483647)
#define MIN_fgINT32 (-2147483647-1)

#define MAX_fgINT64 (9223372036854775807LL)
#define MIN_fgINT64 (-(9223372036854775807LL)-1)

#define MAX_fgFLOAT32 3.4e37
#define MIN_fgFLOAT32 -3.4e-37

#define MAX_fgFLOAT64 1.7e307  
#define MIN_fgFLOAT64 -1.7e-307

#define FLGR_PI (3.141592653589793238462643383279502884195)
